﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OBUCare.Core.Common
{
    public class EqualityComparer<T> : IEqualityComparer<T>
    {

        Func<T, T, bool> predicate = null;
        Func<T, int> getHashCode = null;

        public EqualityComparer(Func<T, T, bool> predicate, Func<T, int> getHashCode)
        {
            this.predicate = predicate;
            this.getHashCode = getHashCode;
        }

        #region IEqualityComparer<T> Members

        public bool Equals(T x, T y)
        {
            return predicate(x, y);
        }

        public int GetHashCode(T obj)
        {
            return getHashCode(obj);
        }

        #endregion
    }
}
